package com.wgworkshop.pems.common.enums;

/**
 * 学生状态枚举。
 * Created by wlc on 2017/7/2.
 */
public enum StudentStatusEnum {
    AT_SCHOOL(1), LEAVE_SCHOOL(2);

    private final Integer code;

    StudentStatusEnum(Integer code) {
        this.code = code;
    }

    public static StudentStatusEnum fromCode(Integer code) {
        if (code == 1) {
            return AT_SCHOOL;
        }
        if (code == 2) {
            return LEAVE_SCHOOL;
        }
        throw new UnsupportedOperationException("The code " + code + " is not supported.");
    }

    public Integer getCode() {
        return code;
    }
}
